package com.luobd.db;

import com.luobd.db.impl.DmMetadataFetcher;
import com.luobd.db.impl.HiveMetadataFetcher;
import com.luobd.db.impl.MySQLMetadataFetcher;
import com.luobd.db.impl.OracleMetadataFetcher;

import java.sql.Connection;

public class MetadataFetcherFactory {

    public static MetadataFetcher createFetcher(DatabaseConfig config, Connection conn) {
            switch (config.getDbType()) {
                case MYSQL: return new MySQLMetadataFetcher(conn, config.getDbName());
                case ORACLE: return new OracleMetadataFetcher(conn, config.getSchema());
                case HIVE: return new HiveMetadataFetcher(conn, config.getDbName());
                case DM: return new DmMetadataFetcher(conn, config.getSchema());
                default: throw new IllegalArgumentException("Unsupported database");
            }
    }

}
